home *** CD-ROM | disk | FTP | other *** search
/ Netware Super Library / Netware Super Library.iso / remote / jservr / jsuper.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-23  |  23.2 KB  |  783 lines

  1. /*****************************************************************************
  2.  *
  3.  * Program Name:    jsuper.exe
  4.  *
  5.  * Filename:         jsuper.c
  6.  *
  7.  * Date Created:    2/2/89
  8.  *
  9.  * Version:             1.0
  10.  *
  11.  * Programmers:     Greg Peto
  12.  *
  13.  * Files used:
  14.  *
  15.  * Date Modified: 
  16.  *
  17.  * Modifications: 
  18.  *
  19.  * Comments:      
  20.  *
  21.  *        To locate where global variables are initialized or set, look at
  22.  *            ComAndInit for command line settings or for the variables as
  23.  *            output variables passed to a function call.
  24.  ****************************************************************************/
  25.  
  26. /* functions in this file:
  27. */
  28. #include    "..\genjob.h"
  29. #include <sys\types.h>
  30. #include <sys\stat.h>
  31.  
  32. /* constants definitions */
  33. #define    MAX_MOD_USERS        10            /* max number of user modify specs */
  34. #define    MAX_PATH_NAME        119        /* max directory path name */
  35. #define    MAX_JOBS                20            /* maximum number of jobs will display */
  36.  
  37. /* global variables and data types */
  38. #define    COM_AUSER    1
  39. #define    COM_AOPER    COM_AUSER        + 1
  40. #define    COM_ASERVER    COM_AOPER        + 1
  41. #define    COM_CREATE    COM_ASERVER        + 1
  42. #define    COM_DESTROY    COM_CREATE        + 1
  43. #define    COM_DUSER    COM_DESTROY        + 1
  44. #define    COM_DOPER    COM_DUSER        + 1
  45. #define    COM_DSERVER    COM_DOPER        + 1
  46. #define    COM_MEMBERS    COM_DSERVER        + 1
  47. #define    COM_JOBS        COM_MEMBERS        + 1
  48. #define    COM_QUEUE    COM_JOBS            + 1
  49. #define    COM_SERVER    COM_QUEUE        + 1
  50.  
  51. COMMAND_ARGS command_args[] =
  52.     /* token,                keyword                num sig,    req. string,    req. int */
  53. {
  54.     {COM_AUSER,                "AUSER",                2,            TRUE,            FALSE},
  55.     {COM_AOPER,                "AOPER",                2,            TRUE,            FALSE},
  56.     {COM_ASERVER,            "ASERVER",              2,            TRUE,            FALSE},
  57.     {COM_CREATE,            "CREATE",            1,            FALSE,        FALSE},
  58.     {COM_DESTROY,            "DESTROY",            2,            FALSE,        FALSE},
  59.     {COM_DUSER,                "DUSER",                2,            TRUE,            FALSE},
  60.     {COM_DOPER,                "DOPER",                2,            TRUE,            FALSE},
  61.     {COM_DSERVER,            "DSERVER",            2,            TRUE,            FALSE},
  62.     {COM_MEMBERS,            "MEMBERS",            1,            FALSE,        FALSE},
  63.     {COM_INFO,                "INFO",                1,            FALSE,        FALSE},
  64.     {COM_QUEUE,                "QUEUE",                1,            TRUE,            FALSE},
  65.     {COM_SERVER,            "SERVER",            1,            TRUE,            FALSE},
  66. };
  67. /* Boolean values set by command line options */
  68. BOOLEAN    wantCreateQueue;                /* user wants to create queue */
  69. BOOLEAN    wantDestroyQueue;                /* user wants to Destroy queue */
  70. BOOLEAN    show_members    = FALSE;        /* show members of job security groups */
  71. BOOLEAN    show_info        = FALSE;        /* show jobs in queue */
  72.  
  73. char        *jobQueuePathName = "SYS:SYSTEM";    /* absolute path to job
  74.                                                                 queue directory */
  75. /* define array to be filled with command line arguments */
  76. char        addUserNames   [MAX_MOD_USERS][MAX_USER_NAME];
  77. char        deleteUserNames[MAX_MOD_USERS][MAX_USER_NAME];
  78. int        numAddUser;
  79. int        numDeleteUser;
  80. char        addOperNames   [MAX_MOD_USERS][MAX_USER_NAME];
  81. char        deleteOperNames[MAX_MOD_USERS][MAX_USER_NAME];
  82. int        numAddOper;
  83. int        numDeleteOper;
  84. char        addServerNames   [MAX_MOD_USERS][MAX_USER_NAME];
  85. char        deleteServerNames[MAX_MOD_USERS][MAX_USER_NAME];
  86. int        numAddServer;
  87. int        numDeleteServer;
  88.  
  89. /* module specific varables and data types */
  90. /* macro definitions */
  91.  
  92. /*****************************************************************************/
  93.  
  94. main(argc,argv,envp)
  95.     /* Descrip:
  96.             This program provides generic job queue maintenance functions.
  97.        Algorithm:    //
  98.          Parse and handle command line arguments, initialize defaults
  99.             Execute functionality wished.
  100.     */
  101.     /* Input: */
  102. int argc;
  103. char *argv[];
  104. char *envp[];
  105.     
  106. {        /* main // */
  107.     /*--------------------------------------------------main body */
  108.     if (argc == 1)
  109.         BadUsage(NULL);    /* missing command line arguments */
  110.  
  111.     ComAndInit(--argc,++argv,envp);    /* skip past program name */
  112.  
  113.     if (wantDestroyQueue)
  114.     {
  115.         DoDestroyQueue();
  116.         exit(0);
  117.     }
  118.     if (wantCreateQueue)
  119.         DoCreateQueue();
  120.     else if (jobQueueID == 0)
  121.     {
  122.         /* all other operations require queueID be found */
  123.         printf("Job queue not found, use /Create option to create, aborting program.\n");
  124.         exit(1);
  125.     }
  126.  
  127.     if (numAddUser OR numDeleteUser)
  128.         DoModUsers();
  129.     if (numAddOper OR numDeleteOper)
  130.         DoModOpers();
  131.     if (numAddServer OR numDeleteServer)
  132.         DoModServers();
  133.  
  134.     if (show_members)
  135.         DoShowMembers();
  136.  
  137.     if (show_info)
  138.         DoShowInfo();
  139. }        /* of main */
  140.  
  141. /********************************************************************/    
  142.  
  143. BadUsage(message)
  144.     /* Descrip:
  145.             This function is called when a fatal error is detected in the
  146.                 command line.  It displays the command format and options
  147.                 and then exits the program.
  148.        Algorithm:    //
  149.     */
  150.     /* Input: */
  151. char    *message;        /* optional explanatory message */
  152.     /* Output: */
  153.     
  154. {        /* BadUsage // */
  155.     /*--------------------------------------------------main body */
  156.     if (message)
  157.         printf("Error: %s\n\n",message);
  158.     printf("usage: jsubmit [<command parameters>] <command line>\n\n");
  159.     printf("   /AUser=<user/group name> (max in one command line %d)\n",
  160.         MAX_MOD_USERS);
  161.     printf("   /DUser=<user/group name> (max in one command line %d)\n",
  162.         MAX_MOD_USERS);
  163.     printf("   /AOperator=<user/group name> (max in one command line %d)\n",
  164.         MAX_MOD_USERS);
  165.     printf("   /DOperator=<user/group name> (max in one command line %d)\n",
  166.         MAX_MOD_USERS);
  167.     printf("   /AServer=<user/group name> (max in one command line %d)\n",
  168.         MAX_MOD_USERS);
  169.     printf("   /DServer=<user/group name> (max in one command line %d)\n",
  170.         MAX_MOD_USERS);
  171.     printf("   /Create\n");
  172.     printf("   /DEstroy\n");
  173.     printf("   /Jobs\n");
  174.     printf("   /Members\n");
  175.     printf("   /Queue[=<job queue name>\n");
  176.     printf("   /Server=<target server with job queue>\n");
  177.  
  178.     exit(1);
  179. }        /* end of BadUsage */
  180.     
  181. /********************************************************************/
  182.  
  183. ComAndInit(argc,argv,envp)
  184.     /* Descrip:
  185.          This function parses command line input and sets default values.
  186.             Several global variables may be changed from default values by
  187.                 command line arguments.
  188.        Algorithm:    //
  189.          Scans command line arguments, overiding defaults as needed.
  190.                 See top of this file for notes on expected form of command
  191.                     line option and badUsage for specific form of commands.
  192.             Saves remote execution command line in jobClientArea.
  193.             Find server of target queue and save in global variable.
  194.         BUGS:
  195.             Not all command line options implemented yet.
  196.     */
  197.     /* Input: */
  198. int argc;
  199. char *argv[];
  200. char *envp[];
  201.     /* Output: */
  202.     
  203. {        /* ComAndInit // */
  204.     /* name of server with job queue */
  205.     char        queueServerName[MAX_FSERVER_NAME];
  206.     char        argCom[MAX_COM_KEY];            /* command keyword buffer */
  207.     char        argString[MAX_ARG_VAR];        /* command argument variable buffer,
  208.                                                             must be static so remains after
  209.                                                             function quits */
  210.     long        argInt;                            /* numeric argument variable */
  211.     JOB_TIME    argTime;                            /* time parameter */
  212.     JOB_DATE    argDate;                            /* date parameter */
  213.     /*--------------------------------------------------main body */
  214.     queueServerName[0]    = '\0';
  215.  
  216.     for (;argc; --argc, ++argv)
  217.     {
  218.         if (*argv[0] NOT= '/')
  219.             BadUsage("Unrecognized command line argument");
  220.  
  221.         switch (ScanArg((*argv) + 1,command_args,
  222.                     sizeof(command_args)/sizeof(COMMAND_ARGS),
  223.                     argString,&argInt,&argTime,&argDate))
  224.         {
  225.             case    COM_AUSER:        /* add user */
  226.                 if (numAddUser == MAX_MOD_USERS)
  227.                     printf("Maximum users can be added in one command line are %d, rest ignored.\n",
  228.                         MAX_MOD_USERS);
  229.                 else
  230.                     strncpy(addUserNames[numAddUser++],argString,MAX_USER_NAME);
  231.                 break;
  232.             case    COM_AOPER:        /* add oper */
  233.                 if (numAddUser == MAX_MOD_USERS)
  234.                     printf("Maximum operators can be added in one command line are %d, rest ignored.\n",
  235.                         MAX_MOD_USERS);
  236.                 else
  237.                     strncpy(addOperNames[numAddOper++],argString,MAX_USER_NAME);
  238.                 break;
  239.             case    COM_ASERVER:     /* add Server */
  240.                 if (numAddServer == MAX_MOD_USERS)
  241.                     printf("Maximum servers can be added in one command line are %d, rest ignored.\n",
  242.                         MAX_MOD_USERS);
  243.                 else
  244.                     strncpy(addServerNames[numAddServer++],argString,MAX_USER_NAME);
  245.                 break;
  246.             case    COM_CREATE:        /* create queue */
  247.                 wantCreateQueue    = TRUE;
  248.                 break;
  249.             case    COM_DESTROY:        /* Destroy queue */
  250.                 wantDestroyQueue    = TRUE;
  251.                 break;
  252.             case    COM_DUSER:        /* add user */
  253.                 if (numDeleteUser == MAX_MOD_USERS)
  254.                     printf("Maximum users can be deleted in one command line are %d, rest ignored.\n",
  255.                         MAX_MOD_USERS);
  256.                 else
  257.                     strncpy(deleteUserNames[numDeleteUser++],argString,
  258.                         MAX_USER_NAME);
  259.                 break;
  260.             case    COM_DOPER:        /* add operator */
  261.                 if (numDeleteOper == MAX_MOD_USERS)
  262.                     printf("Maximum operators can be deleted in one command line are %d, rest ignored.\n",
  263.                         MAX_MOD_USERS);
  264.                 else
  265.                     strncpy(deleteOperNames[numDeleteOper++],argString,
  266.                         MAX_USER_NAME);
  267.                 break;
  268.             case    COM_DSERVER:        /* add servers */
  269.                 if (numDeleteServer == MAX_MOD_USERS)
  270.                     printf("Maximum servers can be deleted in one command line are %d, rest ignored.\n",
  271.                         MAX_MOD_USERS);
  272.                 else
  273.                     strncpy(deleteServerNames[numDeleteServer++],argString,
  274.                         MAX_USER_NAME);
  275.                 break;
  276.             case    COM_info:        /* show queue info */
  277.                 show_info    = TRUE;
  278.                 break;
  279.             case    COM_MEMBERS:    /* show members of security groups */
  280.                 show_members    = TRUE;
  281.                 break;
  282.             case    COM_QUEUE:        /* queue name */
  283.                 if (strlen(argString) > (MAX_JQUEUE_NAME - 1))
  284.                 {
  285.                     printf("Job queue name length must be less than %d, aborting\n",
  286.                         MAX_JQUEUE_NAME - 1);
  287.                     exit(1);
  288.                 }
  289.                 strcpy(jobQueueName,argString);    /* optional job queue name */
  290.                 break;
  291.             case    COM_SERVER:        /* server name */
  292.                 if (strlen(argString) > (MAX_FSERVER_NAME - 1))
  293.                 {
  294.                     printf("Server name length must be less than %d, aborting\n",
  295.                         MAX_FSERVER_NAME - 1);
  296.                     exit(1);
  297.                 }
  298.                 strcpy(queueServerName,argString);
  299.                 break;
  300.             default:
  301.                 printf("Internal error: ComAndInit");
  302.                 exit(1);
  303.         }   /* end of switch on argCom */
  304.         
  305.     } /* end of for argc loop */
  306.  
  307.     FindJobServer(queueServerName,FALSE);
  308.  
  309. #    if VERB_TEST
  310.         printf("Found server %s, connection ID %x\n",
  311.             queueServerName ? "(default)" : queueServerName,
  312.             jobServerConID);
  313. #    endif
  314. }        /* end of ComAndInit */
  315.     
  316. /********************************************************************/
  317.  
  318. DoCreateQueue()
  319.     /* Descrip:
  320.             This function attempts to create job queue as requested by user.
  321.        Algorithm:    //
  322.     */
  323.     
  324. {        /* DoCreateQueue // */
  325.     int    ccode;
  326.     /*--------------------------------------------------main body */
  327.     if (jobQueueID)
  328.         printf("Job queue specified already exists, can't recreate it.\n");
  329.     /* allow any type of job in queue, no directory handle specified */
  330.     else if (ccode = CreateQueue(jobQueueName,(WORD) OT_JOB_QUEUE,(BYTE) 0,
  331.             jobQueuePathName,&jobQueueID))
  332.         switch (ccode)   /* call unsuccessful */
  333.         {
  334.             case INVALID_PATH:
  335.                 printf("Could not create queue with path name %s.\n",
  336.                     jobQueuePathName);
  337.                 exit(1);
  338.             case OBJECT_ALREADY_EXISTS:
  339.                 printf("Job queue already exists, could not create it.\n");
  340.                 break;
  341.             case INVALID_NAME:
  342.                 printf("Job queue name %s is invalid, create failed.\n",
  343.                     jobQueueName);
  344.                 exit(1);
  345.             case INVALID_BINDERY_SECURITY:
  346.             case NO_OBJECT_CREATE_PRIVILEGE:
  347.             case NO_PROPERTY_CREATE_PRIVILEGE:
  348.                 printf("You do not have sufficient security privileges to create\n");
  349.                 printf("the job queue, must be supervisor equivalent.\n");
  350.                 exit(1);
  351.             case SERVER_BINDERY_LOCKED:
  352.             case BINDERY_FAILURE:
  353.                 printf("Could not access bindery because locked or inoperable,\n");
  354.                 printf("job queue not created.\n");
  355.                 exit(1);
  356.             default:
  357.                 printf("Create job queue call to operating system failed, job queue\n");
  358.                 printf("not created\n");
  359.                 exit(1);
  360.  
  361.         }   /* end of switch on ccode */
  362.     else
  363.         printf("Creation of job queue %s successful\n",jobQueueName);
  364. }        /* end of DoCreateQueue  */
  365.     
  366. /********************************************************************/
  367.  
  368. DoDestroyQueue()
  369.     /* Descrip:
  370.             This function attempts to Destroy a job queue as requested by user.
  371.        Algorithm:    //
  372.     */
  373.     
  374. {        /* DoDestroyQueue // */
  375.     int    ccode;
  376.     /*--------------------------------------------------main body */
  377.     if (jobQueueID == 0)
  378.         printf("Unable to locate job queue specified to destroy it.\n");
  379.     else if (ccode = DestroyQueue(jobQueueID))
  380.         switch (ccode)   /* call unsuccessful */
  381.         {
  382.             case NO_QUEUE:
  383.                 printf("Job queue does not exist, could not destroy it.\n");
  384.                 break;
  385.             case INVALID_BINDERY_SECURITY:
  386.             case NO_OBJECT_CREATE_PRIVILEGE:
  387.             case NO_PROPERTY_CREATE_PRIVILEGE:
  388.                 printf("You do not have sufficient security privileges to destroy\n");
  389.                 printf("the job queue, must be supervisor equivalent.\n");
  390.                 exit(1);
  391.             case SERVER_BINDERY_LOCKED:
  392.             case BINDERY_FAILURE:
  393.                 printf("Could not access bindery because locked or inoperable,\n");
  394.                 printf("job queue not destroyed.\n");
  395.                 exit(1);
  396.             default:
  397.                 printf("Destroy queue call to operating system failed, job queue\n");
  398.                 printf("not destroyed.\n");
  399.                 exit(1);
  400.  
  401.         }   /* end of switch on ccode */
  402.     else
  403.         printf("Job queue %s destroyed.\n",jobQueueName);
  404. }        /* end of DoDestroyQueue  */
  405.     
  406. /********************************************************************/
  407.  
  408. DoModUsers()
  409.     /* Descrip:
  410.             This routine actually adds ro deletes members of the queue's
  411.                 Q_USERS property.
  412.             Will look for user as type OT_USER first, and then OT_GROUP.
  413.        Algorithm:    //
  414.     */
  415.     /* Input: */
  416.     /* Output: */
  417.     
  418. {        /* // */
  419.     int            ccode;
  420.     reg int        i;
  421.     int            objectType;
  422.     /*--------------------------------------------------main body */
  423.     for (i = 0; i < numAddUser; ++i)
  424.     {
  425.         if ((objectType    = FindUserClassType(addUserNames[i])) < 0)
  426.             continue;
  427.  
  428.         if ((ccode = AddBinderyObjectToSet(jobQueueName,OT_JOB_QUEUE,"Q_USERS",
  429.             addUserNames[i],objectType)) NOT= 0)
  430.             switch (ccode)
  431.             {
  432.                 case MEMBER_ALREADY_EXISTS:
  433.                     printf("%s already a member of queue user set.\n",addUserNames[i]);
  434.                     break;
  435.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  436.                     goto no_privilege;
  437.                 default:
  438.                     printf("Unable to add user %s to Q_USERS property of queue.\n",
  439.                         addUserNames[i]);
  440.             }    /* end of switch ccode */
  441.     }
  442.  
  443.     for (i = 0; i < numDeleteUser; ++i)
  444.     {
  445.         if ((objectType    = FindUserClassType(deleteUserNames[i])) < 0)
  446.             continue;
  447.  
  448.         if ((ccode = DeleteBinderyObjectFromSet(jobQueueName,OT_JOB_QUEUE,"Q_USERS",
  449.             deleteUserNames[i],objectType)) NOT= 0)
  450.             switch (ccode)
  451.             {
  452.                 case NO_SUCH_MEMBER:
  453.                     printf("%s not a member of queue user set.\n",
  454.                         deleteUserNames[i]);
  455.                     break;
  456.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  457.                     goto no_privilege;
  458.                 default:
  459.                     printf("Unable to delete user %s from Q_USERS property of queue.\n",
  460.                         deleteUserNames[i]);
  461.             }    /* end of switch ccode */
  462.     }
  463.  
  464.     return;
  465.  
  466. no_privilege:    /* abort exit */
  467.     printf("Insufficient security privileges to modify Q_USERS property of queue.\n");
  468.     printf("All user add and delete command line options ignored.\n");
  469. }        /* end of DoModUsers */
  470.     
  471. /********************************************************************/
  472.  
  473. int FindUserClassType(objectName)
  474.     /* Descrip:
  475.             This function looks for specified object first as OT_USER type,
  476.                 then as OT_GROUP.
  477.             If it fails it returns -1.
  478.        Algorithm:    //
  479.     */
  480.     /* Input: */
  481. char        *objectName;
  482.     
  483. {        /* // */
  484.     long    objectID;
  485.     /*--------------------------------------------------main body */
  486.     if (GetBinderyObjectID(objectName,OT_USER, &objectID) == 0)
  487.         return(OT_USER);
  488.     if (GetBinderyObjectID(objectName,OT_USER_GROUP,&objectID) == 0)
  489.         return(OT_USER_GROUP);
  490.  
  491.     printf("Unable to find \"%s\" as a user or a group.\n",
  492.         objectName);
  493.     return(-1);
  494. }        /* end of FindUserClassType */
  495.     
  496. /********************************************************************/
  497.  
  498. DoModOpers()
  499.     /* Descrip:
  500.             This routine actually adds ro deletes members of the queue's
  501.                 Q_OPERATORS property.
  502.        Algorithm:    //
  503.     */
  504.     /* Input: */
  505.     /* Output: */
  506.     
  507. {        /* // */
  508.     int            ccode;
  509.     reg int        i;
  510.     int            objectType;
  511.     /*--------------------------------------------------main body */
  512.     for (i = 0; i < numAddOper; ++i)
  513.     {
  514.         if ((objectType    = FindUserClassType(addOperNames[i])) < 0)
  515.             continue;
  516.  
  517.         if ((ccode = AddBinderyObjectToSet(jobQueueName,OT_JOB_QUEUE,
  518.             "Q_OPERATORS",addOperNames[i],objectType)) NOT= 0)
  519.             switch (ccode)
  520.             {
  521.                 case MEMBER_ALREADY_EXISTS:
  522.                     printf("%s already a member of queue operator set.\n",addOperNames[i]);
  523.                     break;
  524.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  525.                     goto no_privilege;
  526.                 default:
  527.                     printf("Unable to add operator %s to Q_OPERATORS property of queue.\n",
  528.                         addOperNames[i]);
  529.             }    /* end of switch ccode */
  530.     }
  531.  
  532.     for (i = 0; i < numDeleteOper; ++i)
  533.     {
  534.         if ((objectType    = FindUserClassType(deleteOperNames[i])) < 0)
  535.             continue;
  536.  
  537.         if ((ccode = DeleteBinderyObjectFromSet(jobQueueName,OT_JOB_QUEUE,"Q_OPERATORS",
  538.             deleteOperNames[i],objectType)) NOT= 0)
  539.             switch (ccode)
  540.             {
  541.                 case NO_SUCH_MEMBER:
  542.                     printf("%s not a member of queue operator set.\n",
  543.                         deleteOperNames[i]);
  544.                     break;
  545.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  546.                     goto no_privilege;
  547.                 default:
  548.                     printf("Unable to delete operator %s from Q_OPERATORS property of queue.\n",
  549.                         deleteOperNames[i]);
  550.             }    /* end of switch ccode */
  551.     }
  552.  
  553.     return;
  554.  
  555. no_privilege:    /* abort exit */
  556.     printf("Insufficient security privileges to modify Q_OPERATORS property of queue.\n");
  557.     printf("All operator add and delete command line options ignored.\n");
  558. }        /* end of DoModOpers */
  559.     
  560. /********************************************************************/
  561.  
  562. DoModServers()
  563.     /* Descrip:
  564.             This routine actually adds ro deletes members of the queue's
  565.                 Q_SERVERS property.
  566.        Algorithm:    //
  567.     */
  568.     /* Input: */
  569.     /* Output: */
  570.     
  571. {        /* // */
  572.     int            ccode;
  573.     reg int        i;
  574.     int            objectType;
  575.     /*--------------------------------------------------main body */
  576.     for (i = 0; i < numAddServer; ++i)
  577.     {
  578.         if ((objectType    = FindUserClassType(addServerNames[i])) < 0)
  579.             continue;
  580.  
  581.         if ((ccode = AddBinderyObjectToSet(jobQueueName,OT_JOB_QUEUE,"Q_SERVERS",
  582.             addServerNames[i],objectType)) NOT= 0)
  583.             switch (ccode)
  584.             {
  585.                 case MEMBER_ALREADY_EXISTS:
  586.                     printf("%s already a member of queue server set.\n",addServerNames[i]);
  587.                     break;
  588.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  589.                     goto no_privilege;
  590.                 default:
  591.                     printf("Unable to add server %s to Q_SERVERS property of queue.\n",
  592.                         addServerNames[i]);
  593.             }    /* end of switch ccode */
  594.     }
  595.  
  596.     for (i = 0; i < numDeleteServer; ++i)
  597.     {
  598.         if ((objectType    = FindUserClassType(deleteServerNames[i])) < 0)
  599.             continue;
  600.  
  601.         if ((ccode = DeleteBinderyObjectFromSet(jobQueueName,OT_JOB_QUEUE,
  602.             "Q_SERVERS",deleteServerNames[i],objectType)) NOT= 0)
  603.             switch (ccode)
  604.             {
  605.                 case NO_SUCH_MEMBER:
  606.                     printf("%s not a member of queue server set.\n",
  607.                         deleteServerNames[i]);
  608.                     break;
  609.                 case NO_PROPERTY_WRITE_PRIVILEGE:
  610.                     goto no_privilege;
  611.                 default:
  612.                     printf("Unable to delete server %s from Q_SERVERS property of queue.\n",
  613.                         deleteServerNames[i]);
  614.             }    /* end of switch ccode */
  615.     }
  616.  
  617.     return;
  618.  
  619. no_privilege:    /* abort exit */
  620.     printf("Insufficient security privileges to modify Q_SERVERS property of queue.\n");
  621.     printf("All server add and delete command line options ignored.\n");
  622. }        /* end of DoModServers */
  623.     
  624. /********************************************************************/
  625.  
  626. DoShowMembers()
  627.     /* Descrip:
  628.             This function displays all the members of the current security
  629.                 groups.
  630.        Algorithm:    //
  631.     */
  632.     /* Input: */
  633.     /* Output: */
  634.     
  635. {        /* // */
  636.     /*--------------------------------------------------main body */
  637.     ShowSetMembers("Q_USERS",        "users");
  638.     ShowSetMembers("Q_OPERATORS",    "operators");
  639.     ShowSetMembers("Q_SERVERS",    "servers");
  640.     printf("\n");
  641. }        /* end of DoShowMembers */
  642.     
  643. /********************************************************************/
  644.  
  645. ShowSetMembers(set_name,set_desc)
  646.     /* Descrip:
  647.        Algorithm:    //
  648.     */
  649.     /* Input: */
  650. char    *set_name;
  651. char    *set_desc;
  652.     
  653. {        /* // */
  654.     int        segmentNumber;
  655.     BOOLEAN    foundSegment;
  656.     int        ccode;
  657.     long        propertyValue[128/sizeof(long)];        /* objectID's of members */
  658.     BYTE        moreSegments;
  659.     BYTE        propertyFlags;
  660.     reg int    ID_index;
  661.     char        objectName[MAX_USER_NAME];
  662.     WORD        objectType;
  663.     /*--------------------------------------------------main body */
  664.     foundSegment    = FALSE;
  665.     printf("Registered queue %s:\n",set_desc);
  666.     for (segmentNumber = 1, moreSegments = TRUE;
  667.           moreSegments;
  668.           ++segmentNumber)
  669.     {
  670.         ccode    = ReadPropertyValue(jobQueueName,OT_JOB_QUEUE,set_name,
  671.                         segmentNumber,(BYTE *) propertyValue,&moreSegments,
  672.                         &propertyFlags);
  673.         if (ccode != 0)
  674.             moreSegments    = FALSE;
  675.         else
  676.         {
  677.             foundSegment    = TRUE;
  678.             for (ID_index = 0;
  679.                   propertyValue[ID_index] != 0 AND ID_index < 128;
  680.                   ++ID_index)
  681.             {
  682.                 ccode = GetBinderyObjectName(LongSwap(propertyValue[ID_index]),
  683.                                 objectName,&objectType);
  684.                 if (ccode)
  685.                     printf("   Bad objectID in %s property.\n",set_name);
  686.                 else
  687.                     printf("   %s\n",objectName);
  688.             }
  689.         }
  690.     }
  691.     if (foundSegment == FALSE)
  692.         printf("   No registered members\n");
  693. }        /* end of ShowSetMembers */
  694.     
  695. /********************************************************************/
  696.  
  697. DoShowInfo()
  698.     /* Descrip:
  699.             Show queue status, attached servers, and jobs in queue.
  700.     */
  701.     
  702. {        /* // */
  703.     /*--------------------------------------------------main body */
  704.     DoShowStatus();
  705.     DoShowAttachedServer();
  706.     DoShowJobs();
  707. }        /* end of DoShowInfo */
  708.     
  709. /********************************************************************/
  710.  
  711. DoShowStatus()
  712.     /* Descrip:
  713.             Display current status of queue.
  714.     */
  715.     
  716. {        /* // */
  717.     /*--------------------------------------------------main body */
  718. }        /* end of DoShowStatus */
  719.     
  720. /********************************************************************/
  721.  
  722. DoShowAttachedServers()
  723.     /* Descrip:
  724.             Display list of attached servers.
  725.     */
  726.     
  727. {        /* // */
  728.     /*--------------------------------------------------main body */
  729. }        /* end of DoShowAttachedServers */
  730.     
  731. /********************************************************************/
  732.  
  733. DoShowJobs()
  734.     /* Descrip:
  735.             This function will display information about all jobs in the
  736.                 job queue.
  737.        Algorithm:    //
  738.     */
  739.     
  740. {        /* // */
  741.     int            ccode;
  742.     int            i;
  743.     WORD            jobCount;
  744.     WORD            jobNumberList[MAX_JOBS];
  745.     JobStruct    job;
  746.     /*--------------------------------------------------main body */
  747.     ccode    = GetQueueJobList(jobQueueID,&jobCount,jobNumberList,MAX_JOBS);
  748.     if (ccode)
  749.     {
  750.         if (ccode == NO_Q_RIGHTS)
  751.             printf("Insufficient rights to look at jobs in queue\n");
  752.         else
  753.             printf("Unable to get number of jobs in queue\n");
  754.         return;
  755.     }
  756.  
  757.     if (jobCount == 0)
  758.     {
  759.         printf("Job queue empty (no jobs)\n");
  760.         return;
  761.     }
  762.     printf(" Job      Job     Job     DOS\n");
  763.     printf("Number  Position  Type  Command\n");
  764.     printf("------  --------  ----  -------\n");
  765.     for (i = 0; i < jobCount; ++i)
  766.     {
  767.         ccode    = ReadQueueJobEntry(jobQueueID,jobNumberList[i],&job);
  768.         if (ccode)
  769.             printf("Internal error: DoShowJobs, ReadQueueJobEntry\n");
  770.         else
  771.         {    /* print job structure fields */
  772.             printf("  %2d",        job.jobNumber);
  773.             printf("       %2d",    job.jobPosition);
  774.             printf("      %2d",    job.jobType);
  775.             printf("   %s\n",
  776.                 ((CLIENT_REC_AREA *) job.clientRecordArea)->jobCommand);
  777.         }    /* end of if ReadQueueJobEntry ccode else */
  778.     }    /* end of for i loop */
  779.     printf("\n");
  780. }        /* end of DoShowJobs */
  781.     
  782. /********************************************************************/
  783.